package com.sponsorpay.sdk.android.utils;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import java.util.UUID;

public class UserId
{
  public static final String STATE_GENERATED_USERID_KEY = "STATE_GENERATED_USERID_KEY";

  private static String generateUserId(HostInfo paramHostInfo)
  {
    StringBuilder localStringBuilder = new StringBuilder();
    String str1 = paramHostInfo.getUDID();
    String str2 = paramHostInfo.getAndroidId();
    String str3 = paramHostInfo.getHardwareSerialNumber();
    if (isValidId(str1))
      localStringBuilder.append(str1);
    if (isValidAndroidId(str2))
      localStringBuilder.append(str2);
    if (isValidId(str3))
      localStringBuilder.append(str3);
    if (localStringBuilder.length() == 0)
      localStringBuilder.append(UUID.randomUUID());
    String str4 = localStringBuilder.toString();
    String str5 = SignatureTools.generateSHA1ForString(str4);
    if ((str5 == null) || (str5.equals("nosha1")))
      str5 = str4;
    return str5;
  }

  public static String getAutoGenerated(Context paramContext, HostInfo paramHostInfo)
  {
    try
    {
      SharedPreferences localSharedPreferences = paramContext.getSharedPreferences("SponsorPayPublisherState", 0);
      String str = localSharedPreferences.getString("STATE_GENERATED_USERID_KEY", null);
      if (str == null)
      {
        str = generateUserId(paramHostInfo);
        SharedPreferences.Editor localEditor = localSharedPreferences.edit();
        localEditor.putString("STATE_GENERATED_USERID_KEY", str);
        localEditor.commit();
      }
      return str;
    }
    finally
    {
    }
  }

  private static boolean isValidAndroidId(String paramString)
  {
    return (isValidId(paramString)) && (!paramString.equals("9774d56d682e549c"));
  }

  private static boolean isValidId(String paramString)
  {
    if (StringUtils.nullOrEmpty(paramString));
    while (true)
    {
      return false;
      try
      {
        Integer localInteger2 = Integer.valueOf(Integer.parseInt(paramString));
        localInteger1 = localInteger2;
        if ((localInteger1 != null) && (localInteger1.intValue() == 0))
          continue;
        return true;
      }
      catch (NumberFormatException localNumberFormatException)
      {
        while (true)
          Integer localInteger1 = null;
      }
    }
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.sponsorpay.sdk.android.utils.UserId
 * JD-Core Version:    0.6.2
 */